package com.situ.ssm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.situ.ssm.mapper.StudentMapper;
import com.situ.ssm.pojo.bo.StudentSearchBO;
import com.situ.ssm.pojo.entity.Student;
import com.situ.ssm.service.IStudentService;
import com.situ.ssm.util.JSONResult;

@Service
public class StudentServiceImpl implements IStudentService{
	@Autowired
	private StudentMapper studentMapper;

	@Override
	public List<Student> selectAll() {
		return studentMapper.selectAll();
	}

	@Override
	public JSONResult selectByPage(StudentSearchBO studentSearchBO, Integer page, Integer limit) {
		int offset = (page - 1) * limit;
		List<Student> list = studentMapper.selectByPage(studentSearchBO, offset, limit);
		
		int count = studentMapper.selectTotalCount(studentSearchBO);
		
		return JSONResult.ok(list, count);
	}

}
